import http from "./http";

interface ListConfig {
  pageSize: number;
  currentPage: number;
}

export const getColumnList = (options: ListConfig) =>http({ method: "get", url: "/columns", data: options });


//登录接口
interface LoginApi {
  email: string,
  password: string | number
}
export const LoginApi = (options: LoginApi) => http({ method: 'post', url: 'user/login', data: options })



//用户信息
export const getuserlist = () => {
  return http({
    url: 'user/current',
    method: 'get',
  })
}

//注册接口
interface UserRegister {
  email: string,
  nickName: string,
  password: string,
  repetitionPassword: string | number
}
export const registerApi = (options: UserRegister) => http({ url: 'users/', method: 'post', data: options })

//图片上传
export const uploadFile = (options: any) => {
  console.log(options);
  return http({
    method: 'post',
    url: 'upload',
    data: options
  })
}

//填加内容-http://api.vikingship.xyz/api/posts
interface AddarticleConfig {
  title: string,
  content: string,
  image?: string,//可有可无
  author: string,
  column: string
}
export const addArticle = (options: AddarticleConfig) => http({ method: 'post', url: 'posts', data: options })
